package com.cn.service.impl;

import com.cn.mapper.AdminMapper;
import com.cn.entity.Admin;
import com.cn.service.AdminService;
import com.cn.vo.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    public Admin login(String accountNumber, String adminPassword){
        return adminMapper.login(accountNumber,adminPassword);
    }

    public PageResult<Admin> getAdminList(int page, int nums){
        PageHelper.startPage(page, nums);
        List<Admin> list = adminMapper.getList();
        PageInfo<Admin> pageInfo = new PageInfo<>(list);
        return new PageResult<>(pageInfo.getTotal(), pageInfo.getList());
    }

    public boolean addAdmin(Admin admin){
        return adminMapper.insert(admin)==1;
    }

}
